<!DOCTYPE html>
<html lang="en"  xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
  <form id="form_id">
    <input type="hidden" name="cid" th:value="${car.cid}"><br>
    汽车品牌:<input type="text" name="cname" th:value="${car.cname}"><br>

    上市时间:<input type="date" name="cdate" th:value="${#dates.format(car.cdate,'yyyy-MM-dd')}"><br>

    <div class="form-group">
      <label for="myFile">上传文件</label>
      <input type="file" id="myFile" name="myFile" multiple/>
      <input type="text" name="cimg" id="cimg" th:value="${car.cimg}">
    </div>

    <div class="aditor">
      汽车介绍:<textarea name="ccontent">[[${car.ccontent}]]</textarea><br>
    </div>

    汽车类型 :<select name="ctype">
    <option value="-1">请选择</option>
    <option value="1"  th:selected="${car.ctype == 1}">轿车</option>
    <option value="2"  th:selected="${car.ctype == 2}">客车</option>
    <option value="3"  th:selected="${car.ctype == 3}">越野车</option>
    <option value="4"  th:selected="${car.ctype == 4}">牵引车</option>`
</select><br>
</form>
</body>
</html>
<script>
  $(function(){
    CKEDITOR.replace("ccontent");
    $('#myFile').fileinput({
      language: 'zh',
      uploadUrl: '/file/upLoadFile',
      maxFileCount : 5,
      enctype : "multipart/form-data",
      maxFileSize : 1024,
      allowedFileExtensions : ["jpg", "png", "gif"],
      browseClass: 'btn btn-primary',
      initialPreviewAsData: true,//是否初始预览图片
      initialPreviewFileType: 'image',//回显文件类型(初始预览文件类型)
      initialPreview:"/file/download?filename=[[${car.cimg}]]",//图片回显(初始预览图片地址)
    });


    $("#myFile").on("fileuploaded", function(event, data, previewId, index){
      var imgUrl = data.response.imgUrl;
      $("#cimg").val(imgUrl);
    })
  })
</script>